package edu.pku.sei.modeler.neditor.part.policy;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
import org.eclipse.gef.requests.CreateRequest;

import edu.pku.sei.modeler.neditor.ui.CommandCreationFactory;

public class DiagramLayoutEditPolicy extends XYLayoutEditPolicy {

	@Override
	protected Command createChangeConstraintCommand(EditPart child,
			Object constraint) {
		if(!(constraint instanceof Rectangle)){
			System.out.println("unrecongized constraint type :"+constraint.getClass().toString());
			return null;
		} else {
			return CommandCreationFactory.getChangeConstraintCommand(getHost(),child, (Rectangle)constraint);
		}
	}

	@Override
	protected Command getCreateCommand(CreateRequest request) {
		return CommandCreationFactory.getCreateCommand(this.getHost(),request);
	}

}
